package cn.xuchunh.exam;

import java.util.Scanner;

/**
 * Created by XuChunH on 2016/9/9.
 */
public class FindLackedNumber {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int num = 0;
        int lackedIndex = 1;
        int[] result = new int[3];
        int x = 0;
        while(scanner.hasNextInt()  && lackedIndex < 4) {
            num++;
            x = scanner.nextInt();
            if(x - num == lackedIndex){
                result[lackedIndex - 1] = x - 1;
                lackedIndex++;
            }
        }
        System.out.println(Long.valueOf("" + result[0] + result[1] + result[2]) % 7);
    }

}
